package com.example.sharingjdbc4digiwin.mapper;

import com.example.sharingjdbc4digiwin.entity.DataDay;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * @author： ygl
 * @date： 2019/06/22
 * @Description：
 */
@Mapper
public interface DataDayMapper {

    @Insert("insert into data_day values (#{serviceCode},#{serverName},#{warningCount},#{collectedTime})")
    int insert(DataDay model);

    @Select("SELECT * FROM data_day WHERE server_name like CONCAT('%',#{serverName},'%') AND collected_time BETWEEN #{start} AND #{end} order by collected_time limit #{page},3")
    List<DataDay> list(@Param("start") String start, @Param("end")  String end, @Param("page") int page,@Param("serverName") String serverName);


    @Select("select service_code , count(warning_count) from data_day  where service_code like CONCAT('%',#{serviceCode},'%') '%123%'  GROUP BY service_code  ORDER BY service_code desc limit #{page},3")
    List<DataDay> listComplex(@Param("start") String start, @Param("end")  String end, @Param("limitStart") int limitStart, @Param("size") int size , @Param("serviceCode") String serviceCode);

    @Select("select * from data_day where collected_time = #{collectedTime} limit 0,10")
    List<DataDay> find(@Param("collectedTime") String collectedTime);

}
